#include "util.h"

char *itoa(int i)
{
  static char buf[10 + 2];
  char *p = buf + 10 + 1;	/* points to terminating '\0' */
  if (i >= 0) {
    do {
      *--p = '0' + (i % 10);
      i /= 10;
    } while (i != 0);
    return p;
  }
  else {			/* i < 0 */
    do {
      *--p = '0' - (i % 10);
      i /= 10;
    } while (i != 0);
    *--p = '-';
  }
  return p;
}

char * unsigned_itoa(unsigned int i)
{
 
  static char buf[10 + 1];
  char *p = buf + 10 + 1;	/* points to terminating '\0' */
    do {
      *--p = '0' + (i % 10);
      i /= 10;
    } while (i != 0);
    return p;
}